Classes in <stop_token> Header
The <stop_token> header file contains 2 main classes which are:
- stop_source: The stop_source class is used to request cancellation.
- stop_token: The stop_token class is used to check if there is a need to issue the cancellation.
C++ 20 – Header
C++20 has introduced the <stop_token> Header, presenting an alternative method for canceling asynchronous operations. A new class std::stop_token is provided by the <stop_token> header that allows for seamless communication of a termination request between two threads.
In this article, we will discuss the basics of <stop_token> and how to use it in C++20.
Contact Us